www.gusucode.com > 6KBBS ASP版 V7.1 > 6KBBS ASP版 V7.1\code\bbs\Search.asp

    <!--#include file="up.asp"--><!--#include file="inc/page.asp"-->
<link rel="stylesheet" type="text/css" href="skin/<%=Cssstyleid%>/bbs.css">
<%if isnull(lguserid) or lguserid="" then
	tl=" 操 作 失 败"
	mes="对不起,该功能只对会员开放。"
	call sendinfo(tl,mes)
	call down
	response.end
end if
dim action,key,sql,thetime,searchtime,bbs,topicinfo,retopic,reinfo,renum,hot,repage,width,face,n,nn
action=request.querystring("action")
select case action
case""
%>
<div class=searchtitle>论坛搜索</div>
<form method="GET" action="search.asp?action=search">

<div class=searchbody>

<table border="0" cellpadding="0" style="border-collapse: collapse" width="100%">
      <tr>
        <td width="40%">
        <p style="line-height: 120%; margin: 4"><b>搜索关键字:</b><br>请输入要搜索的关键字。</td>
        <td width="60%"> <input type="text" name="key" size="40"></td>
      </tr>
      <tr>
        <td height="35">
        <p style="line-height: 120%; margin: 4"><b>搜索日期范围:</b></td>
        <td> <select size="1" name="searchtime" style="font-size: 9pt">
<option selected value="0">所有日期</option>
<option value="1">1天以来</option>
<option value="2">2天以来</option>
<option value="7">7天以来</option>
<option value="15">15天以来</option>
<option value="30">30天以来</option>
</select></td>
      </tr>
      <tr>
        <td height="35">
        <p style="line-height: 120%; margin: 4"><b>搜索的论坛:</b></td>
        <td> <select size="1" name="bbs" style="font-size: 9pt">
<option value="0">所有论坛</option>
<%set rs=conn.execute("select id,bdinfo from bdinfo where followid<>0 order by orders desc,id")
do while not rs.eof
response.write"<option value="&rs("id")&">"&split(rs("bdinfo"),"|")(0)&"</option>"
rs.movenext
loop
rs.close
set rs=nothing
%></select></td>
      </tr>
      <tr>
        <td colspan="2" align="center" height="40">
        <input type="submit" value="    开 始 搜 索   " name="B1"><input type="hidden" name="action" size="20" value="search"></td>
      </tr>
    </table>

</div>

</form>
<%case"search"
key=Replace(request.querystring("key"),"'","")
key=Replace(key,"[","[[]")
key=Replace(key,"|","│")

if key="" or len(key)<2 or instr("face",key) or checkname(key)=false then
	tl=" 搜 索 失 败"
	mes="<b>搜索关键字太短,或者关键字含有非法字符。</b><br><a href='javascript:history.go(-1)'><img border=0 src="&styleid&"/re.gif align=absmiddle> 返回重新填写</a>"
	call sendinfo(tl,mes)
	call down
	response.end
end if
%>

<%
searchtime=checknum(request.querystring("searchtime"))
bbs=checknum(request.querystring("bbs"))

if grade>12 then 
	sql="select*from topic where topicinfo like '%"&key&"%' and type<>3 and bd not in(select id from bdinfo where type=3 or type=4)"
else
	sql="select*from topic where topicinfo like '%"&key&"%' and type<>3"
end if

if bbs>0 then sql=sql&"and bd="&bbs&" "

if searchtime>0 then sql=sql&"and edittime>now()+"&timeset&"/24-"&searchtime&""

dim wzcount,wzrep,wzpagecount,wzpage,pagestr,urlstr
urlstr="action=search&bbs="&bbs&"&key="&key&"&searchtime="&searchtime
wzrep=application(prefix&"topiclistpage")

set rs = server.createobject("adodb.recordset")
	rs.Open sql,conn,1
		if rs.eof or rs.bof then
			tl="搜索失败"
			mes="搜索不到任何相关的帖子。"
			call sendinfo(tl,mes)
			call down
			response.end

		else
		
			wzcount=rs.recordcount
			
			wzpagecount = abs(int(-abs(wzcount/wzrep)))
			wzpage = clng(request.querystring("page"))
			if len(wzpage) = 0 or wzpage = 0 then wzpage = 1
			rs.absoluteposition=rs.absoluteposition+((abs(wzpage)-1)*wzrep)
			pagestr="每页<font color=red>"&wzrep&"</font>条 共<font color=red>"&wzpagecount&"</font>页 ["&pagination(wzpagecount,urlstr)&"]&nbsp;"
			response.write"<div class=searchpagestr>"&pagestr&"</div>"
			%>
<div class=alltopic><div class=topictop><div class=tface>表情</div><div class=ttopic>主题 (点击表情在新窗口打开)</div><div class=tauthor>作者</div><div class=thits>回复/人气</div><div class=tlastre>最后回复</div></div>

<%
			for i = 0 to wzrep-1
				if rs.eof then exit for
				
				topicinfo=rs("topicinfo")
				topicinfo=split(topicinfo,"|")
				retopic=rs("retopic")
				if isnull(retopic) or retopic="" then
					reinfo="——"
					retopic="未有人回复。|——|0"
					retopic=split(retopic,"|")
				else
					retopic=split(retopic,"|")
					reinfo="<a href=userinfo.asp?userid="&retopic(2)&">"&checktitle(retopic(1))&"</a>"
				end if
				renum=rs("renum")
				hot=checknum(application(prefix&"showbbspage"))
				
				if renum/hot>(renum\hot) then
					repage=(renum\hot)+1
				else
					repage=renum\hot
				end if
				
				width=35
				face=topicinfo(0)
				if rs("type")=1 then face="jing"
				if rs("type")=2 then face="lock"
				
				if rs("top")=1 then face="top"
				if rs("top")=2 then face="alltop"
				if repage>1 then width=25
				
				response.write"<div class=topiclist><div class=tlface><img border=0 src=images/face/"&face&".gif></div><div class=tltopic><a target=_blank href='showbbs.asp?bd="&rs("bd")&"&id="&rs("id")&"&totable="&rs("totable")&"' title='最后回复:"&checktitle(retopic(0))&"'>"&topicinfo(3)&" <font color="&replacecolor(checktitle(topicinfo(1)))&">"&lefttrue(checktitle(topicinfo(1)),width)&"</font></a>"
				
				if repage>1 then
				response.write" <img align=absmiddle border=0 src=images/hot.gif> <span class=hotfont>[</span><b> "
				if repage<=4 then
				for n=1 to repage
				response.write"<a target=_blank href=showbbs.asp?id="&rs("id")&"&bd="&rs("bd")&"&totable="&rs("totable")&"&page="&n&"><span class=hotfont>"&n&"</span></a> "
				next
				else
				for nn=1 to 3
				response.write"<a target=_blank href=showbbs.asp?id="&rs("id")&"&bd="&rs("bd")&"&totable="&rs("totable")&"&page="&nn&"><span class=hotfont>"&nn&"</span></a> "
				next
				response.write"... <a target=_blank href=showbbs.asp?id="&rs("id")&"&bd="&rs("bd")&"&totable="&rs("totable")&"&page="&repage&"><span class=hotfont>"&repage&"</span></a> "
				end if
				response.write" </b><span class=hotfont>]</span>"
				end if
				
				
				response.write"</div><div class=tlauthor><a href=userinfo.asp?userid="&rs("userid")&">"&checktitle(topicinfo(2))&"</a></div><div class=tlhits>"&renum&"/"&rs("hits")&"</div><div class=tllastre>"&reinfo&"<br><span class=tllasttime>"&rs("edittime")&"</span></div></div>"
				
				
				rs.movenext
			next%>
</div>
<%
		end if
	rs.Close
set rs=nothing
response.write"<div class=searchpagestr>"&pagestr&"</div>"
%>

<%end select
call down%>